package com.bilibili.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bilibili.entity.Video;
import com.bilibili.service.SelectVideoService;
import com.bilibili.service.impl.SelectVideoServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;

@WebServlet("/selectVideoCount.do")
public class SelectVideoCountServlet extends HttpServlet {
	
	private SelectVideoService sv= new SelectVideoServiceImpl();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("application/json;charset=utf-8");
		ObjectMapper om=new ObjectMapper();
		String videoId=request.getParameter("videoId");
		int videoid=Integer.parseInt(videoId);
		Video v=sv.selectCount(videoid);
		String countStr=om.writeValueAsString(v);
		response.getWriter().write(countStr);
	}

}
